# copyright (C) Satsang Technologies Limited 2002 - 2007

class ApplicationController < ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_aditi_session_id'
  
  private
  def redirect_to_index(msg=nil)
    flash[:notice] = msg if msg
    if session[:admin_user] == "aditi-admin"
      redirect_to(:action => 'index')
    else
      redirect_to(:controller => 'user', :action => 'index')
    end
  end
  
  def authorize
    unless session[:user_id]
      flash[:notice] = "Please log in"
      redirect_to(:controler => "login", :action => "login")
    end
  end
  
  def logevent
#     removed to save unnecessery database updates during development
#    eventlog = EventLog. new()
#    eventlog.message = User.find(session[:user_id]).username + " : has performed Action : " + request.request_uri 
#    eventlog.event_time = Time.now
#    eventlog.save
  end

end
